package win.demonlegion.controller;

import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import win.demonlegion.eshimin.service.EshiminService;

import java.io.Serializable;

@Controller
//@RequestMapping("callback")
public class CallbackController implements Serializable {
    private static final long serialVersionUID = 3490545092560843580L;
    private static final Logger logger = LoggerFactory.getLogger(CallbackController.class);

    @Autowired
    private EshiminService eshiminService;

    @RequestMapping("callback/test")
    @ResponseBody
    public String test(String platform, String access_token) {
        return eshiminService.generateSign(1652114221150L);
    }

//    @RequestMapping("eshimin")
//    public String eshimin(String platform, ModelMap map) {
//        logger.debug(platform);
//        map.addAttribute("success", "true");
//        return "eshimin_demo";
//    }

    @RequestMapping("callback/eshimin")
    public String eshiminCallback(String code,String params, ModelMap map) {
        logger.info(code);
        logger.info("params: {}", params);
//        eshiminService.getAccessToken(code);
//        logger.info(JSON.toJSONString(eshiminService.userInfoThird(accessToken)));
        map.addAttribute("success", "true");
        return "eshimin_demo";
    }
}
